"""
  模块描述：短连接详情entity
  @author 8526
  @date 2022-05-16 10:27:41
  版权所有 Copyright www.dahantc.com
"""


# 短链接详情响应
class ShortUrlDetailResponse:
    # 账号
    account = ''
    # 明细数据集
    shorturlDetails = []

    def __init__(self, account, shorturlDetails):
        self.account = account
        self.shorturlDetails = shorturlDetails


# 短链接详情响应
class ShortUrlDetailData:
    # 访问的浏览器
    browser = ''
    # 点击次数
    clicknum = 0
    # 设备名称
    device = ''
    # 地址有效期
    expirydate = ''
    # IP地址
    ip = ''
    # 操作系统
    os = ''
    # 点击手机号
    phone = ''
    # 短地址
    shorturl = ''
    # 短链接发送任务编号
    taskid = ''
    # 源地址
    url = ''
    # 点击日期
    wtimeA = ''

    def __init__(self, browser, clicknum, device, expirtdate, ip, os, phone, shorturl, taskid, url, wtimeA):
        self.browser = browser
        self.clicknum = clicknum
        self.device = device
        self.expirydate = expirtdate
        self.ip = ip
        self.os = os
        self.phone = phone
        self.shorturl = shorturl
        self.taskid = taskid
        self.url = url
        self.wtimeA = wtimeA


def shortUrlDetailResponseDecoder(obj):
    if obj is None:
        return None
    return ShortUrlDetailResponse(obj.get('account'),
                                  shortUrlDetailDataDecoder(obj.get('shorturlDetails')))


def shortUrlDetailDataDecoder(obj):
    if obj is None:
        return None
    data = []
    for val in obj:
        data.append(
            ShortUrlDetailData(val.get('browser'), val.get('clicknum'), val.get('device'), val.get('expirydate')
                               , val.get('ip'), val.get('os'), val.get('phone'), val.get('shorturl')
                               , val.get('taskid'), val.get('url'), val.get('wtimeA')))
    return data
